<?php
/**
 * Created by PhpStorm.
 * User: 王世鹏
 * Date: 2018/3/8
 * Time: 15:47
 */

namespace app\index\controller;
use app\index\model\Info as InfoModel;

class FruitShop
{
    public function show()
    {
        $count = input("get.count");
        $supplier = input("get.supplier");
//        $data =InfoModel::all(function($query)use($count,$supplier){

            if(!$count){
                $data = InfoModel::where("supplier","like","%{$supplier}%")->
                paginate(1,false,['query'=>["count"=>$count,"supplier"=>$supplier]]);

//                $query->where("supplier","like","%{$supplier}%");
            }
            elseif (!$supplier){
                $data = InfoModel::where("supplier","like","%{$supplier}%")->
                paginate(1,false,["count"=>$count,"supplier"=>$supplier],['query'=>["count"=>$count,"supplier"=>$supplier]]);
//                $query->where("count","like","%{$count}%");
            }
            else{
//                $query->where("count","like","%{$count}%")->where("supplier","like","%{$supplier}%");
                $data = InfoModel::where("supplier","like","%{$supplier}%")->
                paginate(1,false,["count"=>$count,"supplier"=>$supplier],['query'=>["count"=>$count,"supplier"=>$supplier]]);
            }
//            $query->where("count","like","%{$count}%")->whereOr("supplier","like","{$supplier}");
//        });
        return view("show",["data"=>$data]);


    }



}